import {createRoot} from 'react-dom/client'
import {useReducer,useState,useEffect} from 'react'

function reduce(state,action){
    if(action.type='add'){
        return state+1
    }
    return state
}

let Element=function (){
    let [state,setState]=useState(0)
    useEffect(()=>{
     console.log('update')
        return ()=>{
         console.log('destroy')
        }
    })
    useEffect(()=>{
        console.log('update2')
        return ()=>{
            console.log('destroy2')
        }
    },[])
    useEffect(()=>{
        console.log('update3')
        return ()=>{
            console.log('destroy3')
        }
    })
    let el1=(<button onClick={()=>{
        setState(state)
        setState(state+1)
        setState(state+2)
    }}
     key={1}
    >{state}</button>)
    return el1
}



let root=createRoot(document.getElementById('root'))
root.render(<Element></Element>)